class Solution {
public:
    string minWindow(string s, string t) {
        int s_size = s.size(), t_size = t.size();
        if(t_size > s_size) return "";
        vector<int> hash(256);
        for(auto c : t) ++hash[c];
        int l = 0, r = 0, ret_p = -1, ret_len = 0, cnt = t_size;
        while(r < s_size)
        {
            if(--hash[s[r]] >= 0) --cnt;
            if(cnt == 0)
            {
                while(hash[s[l]] < 0) ++hash[s[l++]];
                if(!ret_len || ret_len > r - l + 1) ret_p = l, ret_len = r - l + 1;
                ++hash[s[l]], ++cnt, ++l;
            }
            ++r;
        }
        return ret_len ? s.substr(ret_p, ret_len) : "";
    }
};